home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / dnsconf / internal.h < prev    next >
C/C++ Source or Header  |  1996-07-26  |  5KB  |  239 lines

  1. #pragma interface
  2. #ifndef INTERNAL_H
  3. #define INTERNAL_H
  4.  
  5. #include <stdio.h>
  6. #ifndef MISC_H
  7.     #include "../misc/misc.h"
  8. #endif
  9.  
  10. #ifndef DNSCONF_H
  11.     #include "dnsconf.h"
  12. #endif
  13.  
  14. class IP_ADDRS: public ARRAY{
  15.     /*~PROTOBEG~ IP_ADDRS */
  16. public:
  17.     IP_ADDR *getitem (int no)const;
  18.     void sort (void);
  19.     /*~PROTOEND~ IP_ADDRS */
  20. };
  21.  
  22. class DNSCONF_HELP_FILE: public HELP_FILE{
  23.     /*~PROTOBEG~ DNSCONF_HELP_FILE */
  24. public:
  25.     DNSCONF_HELP_FILE (const char *fname);
  26.     /*~PROTOEND~ DNSCONF_HELP_FILE */
  27. };
  28.  
  29. struct RECORD_PARSE{
  30.     long ttl;
  31.     bool nottl;
  32.     char f1[200];
  33.     char f2[200];
  34.     char f3[200];
  35.     char f4[200];
  36.     char f5[200];
  37.     char f6[200];
  38.     char f7[200];
  39.     char f8[200];
  40.     /*~PROTOBEG~ RECORD_PARSE */
  41. public:
  42.     RECORD_PARSE (void);
  43.     /*~PROTOEND~ RECORD_PARSE */
  44. };
  45.  
  46.  
  47. // Manage a bunch of open file (open recursivly)
  48. class TBFILE{
  49.     char *defpath;
  50.     int nbopen;
  51.     FILE *tb[10];    // Maximum 10 level of include file
  52. public:
  53.     FILE *cur;    // Current open file
  54.     /*~PROTOBEG~ TBFILE */
  55. public:
  56.     TBFILE (const char *_defpath);
  57.     void fclose (void);
  58.     FILE *fopen (const char *fname, const char *mode);
  59.     ~TBFILE (void);
  60.     /*~PROTOEND~ TBFILE */
  61. };
  62.  
  63.  
  64. class TIMESTR: public SSTRING{
  65. public:
  66.     long seconds;        // Store a duration in seconds
  67.                 // while the SSTRING store it
  68.                 // in hh:mm:ss format
  69.     /*~PROTOBEG~ TIMESTR */
  70. public:
  71.     TIMESTR (long _seconds);
  72.     TIMESTR (void);
  73. private:
  74.     void formatstr (void);
  75. public:
  76.     void setfrom (const char *_str);
  77.     void setfrom (long _seconds);
  78.     /*~PROTOEND~ TIMESTR */
  79. };
  80.  
  81. class RECORD_IN_CNAME: public RECORD_IN{
  82. public:
  83.     IN_NAME nickname;
  84.     IN_NAME name;
  85.     /*~PROTOBEG~ RECORD_IN_CNAME */
  86. public:
  87.     RECORD_IN_CNAME (const RECORD_PARSE&p);
  88.     RECORD_IN_CNAME (const char *cname,
  89.          const char *realname);
  90.     int cmp_left (const char *str);
  91. protected:
  92.     int cmpsame (const RECORD *other);
  93. public:
  94.     void edit (void);
  95.     void print (FILE *fout)const;
  96.     void sethostpart (const char *hostpart);
  97.     /*~PROTOEND~ RECORD_IN_CNAME */
  98. };
  99. class RECORD_IN_SOA: public RECORD_IN{
  100. public:
  101.     SSTRING domain;
  102.     SSTRING machine;
  103.     SSTRING admin;
  104.     long old_serial;
  105.     long new_serial;
  106.     TIMESTR refresh;
  107.     TIMESTR retry;
  108.     TIMESTR expire;
  109.     TIMESTR default_ttl;
  110.     /*~PROTOBEG~ RECORD_IN_SOA */
  111. public:
  112.     RECORD_IN_SOA (const RECORD_PARSE&p);
  113.     RECORD_IN_SOA (void);
  114.     void edit (void);
  115.     void print (FILE *fout)const;
  116.     void update (const char *name);
  117.     /*~PROTOEND~ RECORD_IN_SOA */
  118. };
  119.  
  120. class RECORD_IN_NS: public RECORD_IN{
  121. public:
  122.     IN_NAME name;
  123.     IN_NAME ns;
  124.     /*~PROTOBEG~ RECORD_IN_NS */
  125. public:
  126.     RECORD_IN_NS (const RECORD_PARSE&p);
  127.     RECORD_IN_NS (const char *_name, const char *_ns);
  128.     RECORD_IN_NS (void);
  129.     int cmp_left (const char *str);
  130. protected:
  131.     int cmpsame (const RECORD *other);
  132. public:
  133.     void edit (void);
  134.     void print (FILE *fout)const;
  135.     int set (const RECORD *other);
  136.     void sethostpart (const char *hostpart);
  137.     /*~PROTOEND~ RECORD_IN_NS */
  138. };
  139. class RECORD_IN_MX: public RECORD_IN{
  140. public:
  141.     IN_NAME mailname;
  142.     IN_NAME servname;
  143.     int prefer;
  144.     /*~PROTOBEG~ RECORD_IN_MX */
  145. public:
  146.     RECORD_IN_MX (const RECORD_PARSE&p);
  147.     RECORD_IN_MX (const char *_mailname,
  148.          int priority,
  149.          const char *_servname);
  150.     int cmp_left (const char *str);
  151. protected:
  152.     int cmpsame (const RECORD *other);
  153. public:
  154.     void edit (void);
  155.     void print (FILE *fout)const;
  156.     int set (const RECORD *other);
  157.     void sethostpart (const char *hostpart);
  158.     /*~PROTOEND~ RECORD_IN_MX */
  159. };
  160.  
  161. class RECORD_INCLUDE: public RECORD{
  162. public:
  163.     SSTRING path;
  164.     /*~PROTOBEG~ RECORD_INCLUDE */
  165. public:
  166.     RECORD_INCLUDE (const char *_path);
  167.     void edit (void);
  168.     void print (FILE *fout)const;
  169.     /*~PROTOEND~ RECORD_INCLUDE */
  170. };
  171. // A simple marker for telling the system where the include stops in the
  172. // list. All record are stored in a single list even if they comes from
  173. // include files.
  174. class RECORD_END_INCLUDE: public RECORD{
  175.     /*~PROTOBEG~ RECORD_END_INCLUDE */
  176. public:
  177.     RECORD_END_INCLUDE (void);
  178.     void edit (void);
  179.     void print (FILE *)const;
  180.     /*~PROTOEND~ RECORD_END_INCLUDE */
  181. };
  182.  
  183. struct FQHOST_DECOMP{
  184.     char host[100];
  185.     char domain[100];
  186. };
  187.  
  188. class FQHOST{
  189. public:
  190.     int nbelm;    // Number of variation possible.
  191.             // To speed up manipulation
  192.     FQHOST_DECOMP tb[10];
  193.     /*~PROTOBEG~ FQHOST */
  194. public:
  195.     FQHOST (const SSTRING&host);
  196.     FQHOST (const char *host);
  197.     FQHOST (const char *host, const char *domain);
  198.     void formatfull (SSTRING&full);
  199.     void formatfull (char *full);
  200.     const char *gethostpart (const char *domain);
  201. private:
  202.     void init (const char *host);
  203. public:
  204.     int is_member (const char *domain, char *hostpart);
  205.     /*~PROTOEND~ FQHOST */
  206. };
  207.  
  208. class IPMAP: public ARRAY_OBJ{
  209.     friend class IPMAPS;
  210.     SSTRING iprange;
  211.     IP_ADDR minimum;    // iprange is convert into a minimum/maximum
  212.     IP_ADDR maximum;
  213.     IP_ADDR avail;        // First available IP number in the range
  214.     int over;            // No IP number available in the range
  215.     SSTRING comment;
  216.     /*~PROTOBEG~ IPMAP */
  217. public:
  218.     IPMAP (const char *line);
  219.     IPMAP (void);
  220.     int setup (void);
  221.     void setuse (const IP_ADDR *adr);
  222.     /*~PROTOEND~ IPMAP */
  223. };
  224.  
  225. class IPMAPS: public ARRAY{
  226.     /*~PROTOBEG~ IPMAPS */
  227. public:
  228.     IPMAPS (void);
  229.     void edit (void);
  230.     IPMAP *getitem (int no);
  231.     void save (void);
  232.     void setcombo (class FIELD_COMBO *comb);
  233.     void setuse (IP_ADDRS&adrs);
  234.     /*~PROTOEND~ IPMAPS */
  235. };
  236.  
  237. #endif
  238.  
  239.